<template>
  <div id="wisdomPark-section-v9">
    <MyHeadline title="知识库" :islink="false" style="padding-left: 0px" />
    <MyCell>
      <div class="content">
        <div class="item" v-for="i in data" :key="i">
          <el-progress type="circle" :percentage="25" :stroke-width="20" :color="i.color">
            <template v-slot:default>
              <div class="value" style="color: #fff">{{ i.value }}%</div>
              <div class="" style="color: #fff">{{ i.title }}</div>
            </template>
          </el-progress>
          <div class="value-box">
            <div class="exhibition">
              <div class="exhibition-value">{{ i.accomplish }}</div>
              <div class="exhibition-title">已办理</div>
            </div>
            <div class="exhibition">
              <div class="exhibition-value">{{ i.beBeing }}</div>
              <div class="exhibition-title">处理中</div>
            </div>
          </div>
        </div>
      </div>
    </MyCell>
  </div>
</template>

<script setup lang="ts">
import { ref, onMounted } from 'vue'
import { deepCopy } from '@/utils/utils'
import HtEcharts from '@/base-ui/echarts/index'
import MyCell from '@/components/my-cell/index.vue'
import MyHeadline from '@/components/my-headline/index.vue'
import echartsConfig from '../config/wisdomPark-section-v9/echarts-config'
// ========================= 实例

// ========================= 钩子
onMounted(() => {
  echarts_init()
})

// ========================= 数据

// echarts 配置
const echarts_options = ref(deepCopy(echartsConfig))

// ========================= 函数
// 初始化
const echarts_init = () => {
  onEcharts_data(12)
}
// 数据
const data = ref<any>([
  {
    title: '告警事件',
    color: '#1684fc',
    value: 20,
    accomplish: 300,
    beBeing: 6
  },
  {
    title: '维修事件',
    color: '#e99d42',
    value: 20,
    accomplish: 300,
    beBeing: 6
  }
])

// 随机数
const getRandomInt = (min: number, max: number): number => {
  min = Math.ceil(min)
  max = Math.floor(max)
  return Math.floor(Math.random() * (max - min + 1)) + min
}

// echartsV1数据
const onEcharts_data = (num: number) => {
  const seriesData: any = [
    {
      type: 'bar',
      stack: 'x',
      data: []
    }
  ]
  for (let i = 0; i < num; i++) {
    seriesData[0].data.push(getRandomInt(50, 200))
  }
  echarts_options.value.series = seriesData
}

// ========================= 请求

defineExpose({
  echarts_init
})
</script>

<style scoped lang="less">
#wisdomPark-section-v9 {
  .width_height(100%,100%);
  .font-S-W-C(14px,400,#fff);
  .content {
    .D_J_A(space-between,center);
    width: 100%;
    box-sizing: border-box;
    padding: 0 @space_20 @space_20 @space_20;
    .item {
      .D_F_A(column,center);
      .value {
        margin-bottom: 10px;
      }
      .title {
        margin-top: 10px;
      }
    }
  }
  .value-box {
    .width_height(147px,46px);
    .D_J_A(space-between,center);
    box-sizing: border-box;
    border: 1px solid #bbbbbb;
    background-color: rgba(#fff, 0.2);
    border-radius: 25px;
    margin-top: 10px;
  }
  .exhibition {
    .D_F_A(column,center);
    width: 50%;
    .value {
    }
    .title {
      margin-top: 0px;
    }
  }
}
</style>
